package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HotelPriceHistory;
import com.ruoyi.system.service.IHotelPriceHistoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 酒店历史价格Controller
 * 
 * @author dht
 * @date 2025-04-28
 */
@RestController
@RequestMapping("/system/history")
public class HotelPriceHistoryController extends BaseController
{
    @Autowired
    private IHotelPriceHistoryService hotelPriceHistoryService;

    /**
     * 查询酒店历史价格列表
     */
    @PreAuthorize("@ss.hasPermi('system:history:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotelPriceHistory hotelPriceHistory)
    {
        startPage();
        List<HotelPriceHistory> list = hotelPriceHistoryService.selectHotelPriceHistoryList(hotelPriceHistory);
        return getDataTable(list);
    }

    /**
     * 导出酒店历史价格列表
     */
    @PreAuthorize("@ss.hasPermi('system:history:export')")
    @Log(title = "酒店历史价格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelPriceHistory hotelPriceHistory)
    {
        List<HotelPriceHistory> list = hotelPriceHistoryService.selectHotelPriceHistoryList(hotelPriceHistory);
        ExcelUtil<HotelPriceHistory> util = new ExcelUtil<HotelPriceHistory>(HotelPriceHistory.class);
        util.exportExcel(response, list, "酒店历史价格数据");
    }

    /**
     * 获取酒店历史价格详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:history:query')")
    @GetMapping(value = "/{priceHistoryId}")
    public AjaxResult getInfo(@PathVariable("priceHistoryId") Long priceHistoryId)
    {
        return success(hotelPriceHistoryService.selectHotelPriceHistoryByPriceHistoryId(priceHistoryId));
    }

    /**
     * 新增酒店历史价格
     */
    @PreAuthorize("@ss.hasPermi('system:history:add')")
    @Log(title = "酒店历史价格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelPriceHistory hotelPriceHistory)
    {
        return toAjax(hotelPriceHistoryService.insertHotelPriceHistory(hotelPriceHistory));
    }

    /**
     * 修改酒店历史价格
     */
    @PreAuthorize("@ss.hasPermi('system:history:edit')")
    @Log(title = "酒店历史价格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelPriceHistory hotelPriceHistory)
    {
        return toAjax(hotelPriceHistoryService.updateHotelPriceHistory(hotelPriceHistory));
    }

    /**
     * 删除酒店历史价格
     */
    @PreAuthorize("@ss.hasPermi('system:history:remove')")
    @Log(title = "酒店历史价格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{priceHistoryIds}")
    public AjaxResult remove(@PathVariable Long[] priceHistoryIds)
    {
        return toAjax(hotelPriceHistoryService.deleteHotelPriceHistoryByPriceHistoryIds(priceHistoryIds));
    }
}
